<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>


        // // 数组解构
        // const arr = [1, 2, 3];

        // console.log(arr[0]);
        // console.log(arr[1]);
        // console.log(arr[2]);

        // let [x, y, z] = arr;

        // console.log(x);
        // console.log(y);
        // console.log(z);



        // 对象解构
        const person ={
            name: "木丁西",
            age: 22,
            language: ["English", "中文", "日语"]
        };

        const name = person.name;
        const age = person.age;
        const language = person.language;
        
        console.log(name);
        console.log(age);
        console.log(language);

        // 解构表达式获取值，将 person 里面每一个属性和左边对应赋值
        // const {name, age, language} = person;

        //扩展：如果想要将 name 的值赋值给其他变量，可以如下,myname 是新的变量名
        const {name:myname, age:myage, language:mylanguage} = person;


        console.log(name);
        console.log(myname);
        console.log(myage);
        console.log(mylanguage);




    </script>
</body>

</html>